<template>
	<joy-page class="">
		<view class="uni-list">
			<view class="uni-list-cell" hover-class="uni-list-cell-hover" v-for="(item, index) in kc" :key="index" :data-id="item.curriculumid" @click="goHostCoursesDetail">
				<view class="uni-media-list">
					<image class="uni-media-list-logo" :src="item.picture"></image>
					<view class="uni-media-list-body">
						<view class="uni-media-list-text-top">
							<text style="">{{ item.curriculumname }}</text>
						</view>
						<view class="uni-media-list-text-body">
							<text style="">{{ item.curriculumjj }}</text>
						</view>
						<view class="uni-media-list-text-bottom">
							<text style=""> {{ item.price}} <span>元</span></text>
						</view>
					</view>
					<view style="uni-media-list-bottom"><button class="mini-btn" type="warn" size="mini" style="">立即购买</button></view>
				</view>
			</view>
		</view>
	</joy-page>
</template>

<script>
	import mPageView from "@/components/m-page-view/m-page-view.vue";
	import uniCard from "@/components/uni-card/uni-card.vue";
	import hotCoursesApi from '@/api/hotCourses.js'
	
	let _this
	export default {
		components: {
			"joy-page": mPageView,
			uniCard
		},
		data() {
			return {
				kc:[]
			}
		},
		onLoad(query) {
			_this=this
			_this.initData()
		},

		methods: {
			initData(){
				hotCoursesApi.kc_list().then(res=>{
					console.log(res)
					_this.kc = res.data || []
					_this.kc.forEach((item,index)=>{
						item.curriculumjj=item.curriculumjj.slice(0,10)+'...'
					})
				})
			},
			goHostCoursesDetail(e){
				let {id} = e.currentTarget.dataset
				uni.navigateTo({
					url:`/pages/hotCourses/detail?id=${id}`
				})
			}
			
		},
	}
</script>

<style lang="scss" scoped>
	@import url("../../common/uni/uni.css");
	.uni-list::before,
	.uni-list:after {
		height: 0px;
	}
	button.primary {
		background-color: #0faeff;
	}
	
	.ka {
		width: 100%;
		height: 260upx;
		position: relative;
	
		&:after {
			content: '';
			position: absolute;
			transform-origin: center;
			box-sizing: border-box;
			pointer-events: none;
			top: -50%;
			left: -50%;
			right: -50%;
			bottom: -50%;
			border-bottom: 1px solid $uni-border-color;
			transform: scale(.5);
		}
	}
	
	
	.uni-media-list {
		padding: 10px 10px;
	}
	
	.uni-media-list-logo {
		width: 220upx;
		height: 160upx;
	}
	
	.uni-media-list-body {
		height: auto;
		justify-content: space-around;
	}
	
	.uni-media-list-text-top {
		// height: 60upx;
		font-size: 28upx;
	
	}
	
	.uni-media-list-text-body {
		// height: 60upx;
		font-size: 28upx;
	
	}
	
	.uni-media-list-text-bottom {
		// height: 60upx;
		font-size: 28upx;
	
	}
</style>
